﻿/// <reference path="../app/router.js" />
/// <reference path="../app/vm.js" />
/// <reference path="../app/config.js" />

/**
 @title:        route-config
 @description:  Contain information about routes for whole application. Call the router for registration.
 @author:       Yuriy Shapovalov (shapovalov.yuri@gmail.com)
 */

define('route-config',
    ['config', 'router', 'vm'],
    function (config, router, vm) {
        var
            logger = config.logger,

            register = function () {
                // TODO: route data should come from services (in initial page upload)
                var routeData = [
                    {
                        view: config.viewIds.workspace,
                        // TODO: Not very good format for storing routes information.
                        routes: [
                            {
                                isDefault: true, // TODO: Route should not know about this. Need to move in in config
                                route: config.hashes.workspace,
                                title: 'Workspace',
                                callback: vm.workspace.activate,
                                group: '.route-top'
                            }
                        ]
                    }
                ];

                for (var i = 0; i < routeData.length; i++) {
                    router.register(routeData[i]);
                }

                // TODO: router.run call should be decoupled.
                router.run();
            };

        return {
            register: register
        };
    });